home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / MPW IIGS SC / SC.022.AutoLaunch / debug.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-24  |  2.9 KB  |  111 lines  |  [TEXT/MPS ]

  1. /**********************************************************************
  2. *
  3. * debug.c -- Version 3.0
  4. *
  5. * Copyright (c)
  6. * Apple Computer, Inc.  1988-1990
  7. * All Rights Reserved.
  8. *
  9. * Developer Technical Support Apple II Sample Code
  10. *
  11. * Written by Eric Soldan.
  12. *
  13. **********************************************************************/
  14.  
  15. /* This file contains some simple, yet useful debugging routines
  16. ** for c programmers.  This code is conditionally included.  It
  17. ** depends on productionVersion being 0.  If productionVersion = 0,
  18. ** then the code is included.  You want to make sure that the code is
  19. ** not included in the production version because this code calls
  20. ** sprintf and sprintf is HUGE.  Your program will be about 20k
  21. ** smaller without sprintf.
  22. */
  23.  
  24. /**********************************************************************/
  25. /**********************************************************************/
  26. /**********************************************************************/
  27.  
  28. #include <quickdraw.h>
  29. #include <texttool.h>
  30. #include "autolaunch.h"
  31.  
  32. char    test[80];
  33.  
  34. #if 1
  35. #else
  36.  
  37. /**********************************************************************/
  38.  
  39. /* This code waits for something to be done with the paddle buttons.
  40. ** The openApple and option keys can be used as the buttons.
  41. ** When either the openApple or option key is pressed, the super
  42. ** hi-res screen is displayed.  Depending on which was pressed, one
  43. ** of two things occurs when it is released.  If the option key was
  44. ** pressed, then the text screen is displayed again, and it again
  45. ** waits for a paddle button to be pressed.  This allows you to 
  46. ** jump between the text screen and the super hi-res screen.  If the
  47. ** openApple key was pressed, then when it is released, the routine 
  48. ** returns.  This is the key to be used to continue your application.
  49. ** If both the openApple and option key are pressed, then it returns
  50. ** immediately.  It does not wait for a key to be released.
  51. */
  52.  
  53. void    pdlWait()
  54. {
  55.     unsigned int    i;
  56.  
  57.     for (;;) {
  58.         GrafOff();
  59.         for (;;) {
  60.             for (i = 2; i; i--) {
  61.                 if (*((char *)(0xE0C060 + i)) & 0x80) break;
  62.             }
  63.             if (i) break;
  64.         }
  65.         GrafOn();
  66.         for (; *((char *)(0xE0C060 + i)) & 0x80;) {
  67.             if (*((char *)(0xE0C063 - i)) & 0x80) return;
  68.         }
  69.         if (i == 1) return;
  70.     }
  71. }
  72.  
  73. /**********************************************************************/
  74.  
  75. /* This routine displays a string on the text screen if the openApple
  76. ** key is not being held down.
  77. */
  78.  
  79. void    sbug(str)
  80. char    *str;
  81. {
  82.     if (*((char *)0xE0C061) >= 0x80) return;
  83.     InitTextDev(1);
  84.     WriteCString(str);
  85.     pdlWait();
  86. }
  87.  
  88. /**********************************************************************/
  89.  
  90. /* This routine displays the stack pointer at the point in your
  91. ** application when you call it.  This is useful to determine if
  92. ** you have some stack inbalance in a particular routine, and if
  93. ** so, where it is.
  94. */
  95.  
  96. void    stack()
  97. {
  98.     unsigned int    stk;
  99.  
  100.     asm {
  101.         tsc
  102.         clc
  103.         adc #13
  104.         sta    stk
  105.     }
  106.     sprintf(test, "stack=$%X", stk);
  107.     sbug(test);
  108. }
  109.  
  110. #endif
  111.